<div class="layuimini-container layuimini-page-anim" style="height: 100%">
    <!--按季度显示销售部各组的销售额情况-->
    <div id="container" style="height: 100%"></div>

</div>

<!--图表-->
<script type="text/javascript">
    $(function () {
        /*柱状图*/
        $.ajax({
            url:"/xiaoshou",
            data:{},
            dataType:"json",
            success:function (data){
                var dom = document.getElementById("container");
                var myChart = echarts.init(dom);
                var app = {};
                var dom = document.getElementById("container");
                var myChart = echarts.init(dom);
                var app = {};
                option = null;
                var A1;
                var A2 ;
                var A3 ;
                var A4 ;
                var A5 ;
                var A6 ;
                var A7 ;
                var A8 ;
                var A9 ;
                /*如果返回的数据已经是JSON对象可以使用这种方式获取，不是的话需要使用eval转换一下*/
                for(var i in data){
                    A1 = data[0].value;
                    A2 = data[1].value;
                    A3 = data[2].value;
                    A4 = data[3].value;
                    A5 = data[4].value;
                    A6 = data[5].value
                    A7 = data[6].value;
                    A8 = data[7].value;
                    A9 = data[8].value;

                }

                console.log(A1);
                option = {
                    legend: {text:"销售部分组展示销售额"},
                    tooltip: {},
                    dataset: {
                        dimensions: ['product', 'A组', 'B组', 'C组'],
                        source: [
                            {product: '一季度', 'A组': A1, 'B组': A2, 'C组': A3},
                            {product: '二季度', 'A组': A4, 'B组': A5, 'C组': A6},
                            {product: '三季度', 'A组': A7, 'B组': A8, 'C组': A9}
                        ]
                    },
                    xAxis: {type: 'category'},
                    yAxis: {},
                    series: [
                        {type: 'bar'},
                        {type: 'bar'},
                        {type: 'bar'}
                    ]
                };
                ;
                if (option && typeof option === "object") {
                    myChart.setOption(option, true);
                }
            }
        });
    });

</script>
